package com.zrx.springboot.config;

import com.zrx.springboot.interceptor.PermissionInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 1.编写一个拦截器实现HandlerInterceptor接口
 * 2.拦截器注册到容器中（是实现HandlerInterceptor的addInterceptors方法）
 * 3.指定拦截规则【如果拦截所有静态资源也会被拦截】
 */
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
    //注册拦截器


    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new PermissionInterceptor())
                                .addPathPatterns("/order/**","/cart/**")
                ;
    }
}
